# GASL
# Copyright Matthew F. Rienzo, 2014
#
# Based off Poolang, Copyright Matthew Caswell, 2013

# __START Perl
use strict;
use warnings;
# __END Perl

# __START NonPerl
use GASL::Assembler;
# __END NonPerl

# __START Constants
use constant GASL_VERSION => "N10";
# __END Constants

# __START Compiler
my $GASL_VERSION = GASL_VERSION;

my $inFile = 0;
my $outFile = 0;
my $dbg = 0;

# Version(GASL_VERSION) - Prints versioning info to STDOUT.
sub Version($){
  my $version = shift;
  die "Generic Assembly Language (GASL) version $version\n".
    "GASL/N10 Copyright Matthew F. Rienzo, 2014\n".
	"-- based off Poolang, Copyright Matthew Rienzo, 2013\n";
}

my $__VM_ARGC = 0;
for($__VM_ARGC = 0; $ARGV[$__VM_ARGC]; $__VM_ARGC++){
  if($ARGV[$__VM_ARGC] eq "--debug"){
    $dbg = 1;
  }elsif($ARGV[$__VM_ARGC] eq "--version"){
    Version(GASL_VERSION);
	exit(0);
  }elsif($ARGV[$__VM_ARGC] eq "--in"){
    $inFile = $ARGV[$__VM_ARGC + 1];
	$__VM_ARGC += 1;
  }elsif($ARGV[$__VM_ARGC] eq "--out"){
    $outFile = $ARGV[$__VM_ARGC + 1];
	$__VM_ARGC += 1;
  }else{
    die "Usage: $0 --[version,debug,in <source file>,out <output file>]\n";
  }
}

GASL::Assembler::compile($dbg, $inFile, $outFile);

# __END Compiler

